# Maintainer: Duje Mihanović <duje.mihanovic@skole.hr>

_flavor=samsung-coreprimevelte
pkgname=linux-$_flavor
pkgver=6.13_rc4
_pkgver=${pkgver/_/-}
pkgrel=0
pkgdesc="Samsung Galaxy Core Prime VE LTE mainline kernel"
arch="aarch64"
_carch="arm64"
url="https://gitlab.com/LegoLivesMatter/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native pmb:kconfigcheck-nftables
pmb:kconfigcheck-zram"
makedepends="bash bc bison devicepkg-dev findutils flex gmp-dev mpc1-dev
mpfr-dev openssl-dev perl postmarketos-installkernel dtc"

# Source
_config="config-$_flavor.$arch"
source="
	$pkgname-$_pkgver.tar.gz::$url/-/archive/v$_pkgver-pxa1908/linux-v$_pkgver-pxa1908.tar.gz
	$_config
"
builddir="$srcdir/linux-v$_pkgver-pxa1908"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" "$builddir"/.config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	mkdir -p "$pkgdir"/boot
	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_DTBS_PATH="$pkgdir/usr/share/dtb"

	install -D include/config/kernel.release \
		"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
}

sha512sums="
6709ca2571beff6a71c2da611b0f5c58b1d85a62ccfe371f9bd4cbac12e755bc338731d8091d572edb3e8c7683574693d753d9513a8b873f0be86b3400bac2d0  linux-samsung-coreprimevelte-6.13-rc4.tar.gz
cf91f4962383d757b65551e140cec23ff602842783b44efdfe8eb8e66ccf579ccf76eeafa043dc031d5f8e86ee890353dc462fad81e2d63babe082e657a52ab0  config-samsung-coreprimevelte.aarch64
"
